starting excel

Any ideans?  This doesn't work:

  • OleAutoObj oleExcel = oleCreateAutoObject("Excel.Application")
  • olePut (oaoExcel, "Visible", true)

I get no errors, the handle is "valid"; but there is no such excel.exe appears in Task manager and no displayed Excel.  Am sure it used to work.

This does work; get a "WinWord.exe" application displayed and created.

  • OleAutoObj oleWord = oleCreateAutoObject("Word.Application")

Using v9512, Office 2007, and Windows 7

-Louie

 


llandale - Thu Apr 17 14:09:37 EDT 2014

Re: starting excel
GregM_dxler - Fri Apr 18 09:31:30 EDT 2014

Hi Louie,

In your olePut, you have oaoExcel instead of oleExcel.  But that doesn't fix the problem.

What I am seeing is that excel does start up, but when the script ends, it closes the application.  If I put an ack message box at the end, I can see the excel application.

Interesting, word will stay open, but excel will close....

Hope this helps,

Greg

Re: starting excel
KBSri - Mon Apr 21 02:37:44 EDT 2014

Hello Louie,

I am unable to put the data onto the second worksheet of the EXCEL.

Here is the function:

void get_feature_data()
{
    // Launch Excel Template
    //ExcelInit(true , strTemplate)

    excel_file_path = "C:\\Desktop\\FeatureStatistics1.xlt"
    
    oleExcel = openExcelFile(excel_file_path, true);
                    
    print "\nReading data from Feature Excel..."
                        
    for(k=1; k<5; k++)
    {    
        objExcelSheet = excelGetWorksheet(oleExcel, k)
        if(null objExcelSheet)
        {
            break
        }
        oleGet(objExcelSheet, "Name", sheet_name)
                        
        if(sheet_name == "Feature List" && system_sheet_no == 0)
        {
            system_sheet_no = k
                                                            
            for(i=1; i<=5; i++)
            {
                for j in 1:3 do
                {
                    temp_str = getCellValue(objExcelSheet, j, i)
            
                    if(temp_str == "Feature ID" && system_id_no == 0)   
                    {
                        print "Name of the attribute:" temp_str"\n"
                        system_id_no = i
                                        
                        if(system_id_no != 0)
                        {
                            for (x=1; x<=sys_array_size; ++x)
                            {
                                temp_val = getCellValue(objExcelSheet, x, system_id_no)
                                if(temp_val != "")
                                {
                                    system_FeatureID[x-1] = temp_val
                                    print temp_val"\n"
                                    
                                    put(skip_featureID,x,temp_val)
                                }
                                system_id_ctr++
                            }    
                            print "Count:"system_id_ctr"\n"
                        }
                    }
                    
                }
            }    
        }
        oleCloseAutoObject(objExcelSheet)    
    }
    
    //Quitting Excel
    if(!null oleExcel)
    {
        excelQuit(oleExcel)
    }
    //Calling Run Feature
    print "Calling run feature\n"
    runFeature()
    
    oleExcel = openExcelFile(excel_file_path, true);
    
    ExcelInit(true , strTemplate)
    
    for(k=1; k<5; k++)
    {    
        objExcelSheet = excelGetWorksheet(oleExcel, k)
        if(null objExcelSheet)
        {
            break
        }
        oleGet(objExcelSheet, "Name", sheet_name)
        
        if(sheet_name == "Feature Statistics" && comp_sheet_no == 0)
        {
            comp_sheet_no = k
                            
            for(i=1; i<=5; i++)
            {
                for j in 1:3 do
                {
                    temp_str = getCellValue(objExcelSheet, j, i)
                                        
                    if(temp_str == "System Level")
                    {
                        print "System\n"
                        comp_id_no = i
                        if(comp_id_no != 0)
                        {
                            for (x=1; x<=comp_array_size; ++x)
                            {
                                temp_val = getCellValue(objExcelSheet, x, comp_id_no)
                                if(temp_val != "")
                                {
                                    //comp_FeatureID[x-1] = temp_val
                                    print "Temporary:" temp_val"\n"
                                    //Launch Excel Template    
                                    ExcelPut(2,3,"Test")
                                }
                                comp_id_ctr++
                            }    
                        }
                    }
                    print"Checking for Run Feature Call\n"
                }
            }
        }
    }
    if(running_mode == 1)
    {
        get_feature_data()    
    }
}

I am trying to fetch the data from the EXCEL Sheet and putting it back to the EXCEL second sheet.

This is the function I am referring to put the data on to the next sheet tab on the same EXCEL.

oleExcel = openExcelFile(excel_file_path, true);
    
    ExcelInit(true , strTemplate)
    
    for(k=1; k<5; k++)
    {    
        objExcelSheet = excelGetWorksheet(oleExcel, k)
        if(null objExcelSheet)
        {
            break
        }
        oleGet(objExcelSheet, "Name", sheet_name)
        
        if(sheet_name == "Feature Statistics" && comp_sheet_no == 0)
        {
            comp_sheet_no = k
                            
            for(i=1; i<=5; i++)
            {
                for j in 1:3 do
                {
                    temp_str = getCellValue(objExcelSheet, j, i)
                                        
                    if(temp_str == "System Level")
                    {
                        print "System\n"
                        comp_id_no = i
                        if(comp_id_no != 0)
                        {
                            for (x=1; x<=comp_array_size; ++x)
                            {
                                temp_val = getCellValue(objExcelSheet, x, comp_id_no)
                                if(temp_val != "")
                                {
                                    //comp_FeatureID[x-1] = temp_val
                                    print "Temporary:" temp_val"\n"
                                    //Launch Excel Template    
                                    ExcelPut(2,3,"Test")
                                }
                                comp_id_ctr++
                            }    
                        }
                    }
                    print"Checking for Run Feature Call\n"
                }
            }
        }
    }
    if(running_mode == 1)
    {
        get_feature_data()    
    }
}

 

Any ideas????????????????

 

Re: starting excel
llandale - Tue Apr 22 12:54:27 EDT 2014

GregM_dxler - Fri Apr 18 09:31:30 EDT 2014

Hi Louie,

In your olePut, you have oaoExcel instead of oleExcel.  But that doesn't fix the problem.

What I am seeing is that excel does start up, but when the script ends, it closes the application.  If I put an ack message box at the end, I can see the excel application.

Interesting, word will stay open, but excel will close....

Hope this helps,

Greg

Wow thanks.  Yes strange it closes Excel.  Someone out there knows why.

-Louie

Re: starting excel
Mathias Mamsch - Wed Apr 23 03:20:31 EDT 2014

llandale - Tue Apr 22 12:54:27 EDT 2014

Wow thanks.  Yes strange it closes Excel.  Someone out there knows why.

-Louie

Well I guess it simply closes Excel, because there is nothing open in it ... It is kind of a 'auto cleanup'  feature?

This leaves Excel Open:

OleAutoObj oleExcel = oleCreateAutoObject("Excel.Application") 
olePut (oleExcel , "Visible", true) 

OleAutoObj oleBookz = null, oleBook = null;

oleGet(oleExcel, "Workbooks", oleBookz) 
oleMethod(oleBookz, "Add", null, oleBook)  // Comment me out and Excel will close
oleCloseAutoObject oleBookz

Regards, Mathias

Re: starting excel
llandale - Thu Apr 24 09:37:51 EDT 2014

Mathias Mamsch - Wed Apr 23 03:20:31 EDT 2014

Well I guess it simply closes Excel, because there is nothing open in it ... It is kind of a 'auto cleanup'  feature?

This leaves Excel Open:

OleAutoObj oleExcel = oleCreateAutoObject("Excel.Application") 
olePut (oleExcel , "Visible", true) 

OleAutoObj oleBookz = null, oleBook = null;

oleGet(oleExcel, "Workbooks", oleBookz) 
oleMethod(oleBookz, "Add", null, oleBook)  // Comment me out and Excel will close
oleCloseAutoObject oleBookz

Regards, Mathias

thanks